<?php
class Product_model extends CI_Model{
	function Product_model(){
		parent::__construct();
	}
	
	/**
	 * 
	 * Get all product
	 */
	public function getAll(){
		$data = array();
		
		$q = $this->db->get_where('products',array('public' => '1'));
		
		if($q->num_rows()){
			foreach ($q->result_array() as $row){
				$data[] = $row;
			}
		}
		
		$q->free_result();
		return $data;
	}
	
	public function getSumProductByCatId($id){
		$data = NULL;
		

		$q = $this->db->get_where('products',array('category_id' => $id, 'public' => '1'));
		
		$data = $q->num_rows();
		
		$q->free_result();
		
		return $data;
		
	}
}